<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/default.xhtml">
	
	<f:metadata>
		<f:viewParam
			name="id" 
			value="#{resourceBean.id}" />
		<f:event
			type="preRenderView"
			listener="#{resourceBean.load}" />
	</f:metadata>
	
	<ui:define name="content">
		
		<h:form id="resourceEditForm" rendered = "#{login.loggedIn}">

			<h:outputLabel for="resourceName" value="Resource name: "/>
			<h:panelGroup>
				<p:inputText id="resourceName" value="#{resourceBean.res.name}" />
				<h:message for="resourceName" styleClass="error" />
			</h:panelGroup>
			
			<br /><br />
			
			<p:commandButton 
				value="Save" 
				action="#{resourceBean.save(currentUser)}" />
				
			<p:commandButton 
				value="Remove" 
				action="#{resourceBean.remove()}" rendered="#{resourceBean.id!=null}"/>
				
			<p:button
				value="Back"
				outcome="/content/resource/list" />
		
		</h:form>

	</ui:define>
</ui:composition>